<template>
  <div class="reg">
<Gback />

    <div class="reg_a">
      <input type="text" v-model="username" />
      <input type="password" v-model="password" />
      {{errMess}}
    </div>
    <button @click="reg">注册</button>
  </div>
</template>
<script>
import Gback from '../components/gback'

export default {
     components:{
Gback
    },
  data() {
    return {
      username: "",
      password: "",
      errMess: ""
    };
  },
  methods: {
    reg() {
      this.$axios({
        url: "/api/reg",
        method: 'post',
        data: {
          username: this.username,
          password: this.password
        }
      }).then(res => {
        if (res.data.err === 0) {
          this.$router.replace("/longin");
        } else {
          this.errMess = res.data.msg; //res.data.msg返回回来的错误信息
        }
      });
    }
  }
};
</script>
<style scoped>
/* .reg_a {
   height: 0.8rem; 
} */
.reg_a input {
  height: 0.3rem;
  background-color: aquamarine;
}
</style>